using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public class Player : MonoBehaviour
{
    public float flyForce = 300;
    public Transform bloodexp;
    public float force = 400;
    public int frags;
    public float angularvel = 600;
    public float maxVelocityChange = 10.0f;
    public string Nick;

    void Start()
    {
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);
            rigidbody.angularVelocity = Vector3.zero;
        }
    }
    void FixedUpdate()
    {
        LocalMove();
    }
    void LocalMove()
    {
        if (Screen.lockCursor)
        {
            Vector3 moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            moveDirection = Cam._This.transform.TransformDirection(moveDirection);
            moveDirection.y = 0;
            moveDirection.Normalize();
            this.rigidbody.AddTorque(new Vector3(moveDirection.z, 0, -moveDirection.x) * Time.deltaTime * angularvel);

            this.rigidbody.AddForce(moveDirection * Time.deltaTime * force);
        }
    }
}
